/*************************************************************************
	> File Name: montage_two_pic.cpp
	> Author: 
	> Mail: 
	> Created Time: 2021年05月17日 星期一 18时48分49秒
 ************************************************************************/

/*用两张图（最好用风景），第一张图的透明度从0.1~0.9，第二张图的透明度从0.9~0.1，合成9张图。理解转场动画制作原理。 */

#include <opencv2/opencv.hpp>

using namespace cv;

int main() {
    Mat srcImg1 = imread("../data/scene1.jpg");
    Mat srcImg2 = imread("../data/scene2.jpg");
   
    int height;
    if (srcImg1.rows > srcImg2.rows) {
        height = srcImg2.rows;
    } else {
        height = srcImg1.rows;
    }

    int width;
    if (srcImg1.cols > srcImg2.cols) {
        width = srcImg2.cols;
    } else {
        width = srcImg1.cols;
    }

    resize(srcImg1, srcImg1, Size(width, height));
    resize(srcImg2, srcImg2, Size(width, height));


    Mat destImage;
    addWeighted(srcImg1, 0.1, srcImg2, 0.9, 3, destImage);
    imwrite("(0.1,0.9).jpg", destImage);
    //imshow("(0.1,0.9).jpg", destImage1);
    
    addWeighted(srcImg1, 0.2, srcImg2, 0.8, 3, destImage);
    imwrite("(0.2,0.8).jpg", destImage);
    

    addWeighted(srcImg1, 0.3, srcImg2, 0.7, 3, destImage);
    imwrite("(0.3,0.7).jpg", destImage);


    addWeighted(srcImg1, 0.4, srcImg2, 0.6, 3, destImage);
    imwrite("(0.4,0.6).jpg", destImage);


    addWeighted(srcImg1, 0.5, srcImg2, 0.5, 3, destImage);
    imwrite("(0.5,0.5).jpg", destImage);


    addWeighted(srcImg1, 0.6, srcImg2, 0.4, 3, destImage);
    imwrite("(0.6,0.4).jpg", destImage);

    addWeighted(srcImg1, 0.7, srcImg2, 0.3, 3, destImage);
    imwrite("(0.7,0.3).jpg", destImage);

    addWeighted(srcImg1, 0.8, srcImg2, 0.2, 3, destImage);
    imwrite("(0.8,0.2).jpg", destImage);

    addWeighted(srcImg1, 0.9, srcImg2, 0.1, 3, destImage);
    imwrite("(0.9,0.1).jpg", destImage);
    return 0;
}
